#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
#include<set>
using namespace std;
set<string> s;
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n;
		cin >> n;
		while (n--)
		{
			string s1;
			cin >> s1;
			int len = s1.size();
			for (int i = 0; i < len; i++)
			{
				if (s1[i] >= 'A' && s1[i] <= 'Z') s1[i] += 32;
			}
			s.insert(s1);
		}
		cout << s.size() << endl;
		//for (auto v : s) cout << v << " ";
		//cout << endl;
		s.clear();
	}
	return 0;
}